#include "Application.h"
#include "IListenSocket.h"
#include "SocketThread.h"
#include "MessagePort.h"
#include "WorldThread.h"
#include "EventMgr.h"

namespace cupid
{
DECLARE_SINGLETON_MEMBER(EventMgr);
DECLARE_SINGLETON_MEMBER(Application);
Application::Application(void)
{
	m_socketThread = NULL;
	m_worldThread = NULL;
	m_msgPort = NULL;
	init();
}

Application::~Application(void)
{
	delete m_socketThread;
	delete m_worldThread;
}

void Application::init()
{
	initSocket();
	MessagePort::initPortSet(MSGPORT_WORLD + 1);
	m_msgPort = MessagePort::getInterface(MSGPORT_SHELL);
	m_msgPort->open();
	m_worldThread = new WorldThread(MessagePort::getInterface(MSGPORT_WORLD));
	m_socketThread = new SocketThread(MessagePort::getInterface(MSGPORT_SOCKET));
	m_worldThread->createThread(false);
	m_socketThread->createThread(false);

	m_worldThread->resumeThread();
	m_socketThread->resumeThread();
}
void Application::run()
{
	while (1)
	{
		Sleep(1);
	}
}
}